#ifndef COMMON_H
#define COMMON_H

namespace crossbit {

    typedef unsigned char		XTUint8;
    typedef char				XTInt8;
    typedef unsigned short		XTUint16;
    typedef short				XTInt16;
    typedef unsigned int		XTUint32;
    typedef int					XTInt32;
    typedef unsigned long long	XTUint64;
    typedef long long			XTInt64;

    typedef char *				XTPStr;

    typedef XTUint32			XTMemAddr;
    typedef XTInt32				XTRegNum;
	typedef XTInt32				XTFile;


    // <- temp variable 
    // register number
    typedef short				RegNum;

    typedef XTUint32			MemAddr;
    typedef unsigned long long  DWord;
    typedef unsigned int    	Word;
    typedef unsigned short  	HalfWord;
    typedef unsigned char   	Byte;
    typedef struct _qword{
        DWord low;
        HalfWord high;
    } QWord;

    // temp variable ->

#define __X86__

#ifdef __X86__
#define CONTEXT_SAVE 	     __asm__("pusha");
#define CONTEXT_RESTORE	   __asm__("popa");
#elif __MIPS__
#define CONTEXT_SAVE
#define CONTEXT_RESTORE
#else
#define CONTEXT_SAVE
#define CONTEXT_RESTORE
#endif

#define PAGESIZE 	(1<<12)
#define PAGESTART(x)	((x) & ~(XTUint32)(PAGESIZE-1))
#define PAGEALIGN(x) 	(((x) + PAGESIZE - 1) & ~(PAGESIZE-1))
#define PAGEOFFSET(x) 	((x) & (PAGESIZE-1))

    // Block Size (Byte/HalfXTInt32/XTInt32)
    enum BlockSize {
        BYTE,	    // 8 bit
        HALFWORD,   // 16 bit
        WORD,	    // 32 bit
        DWORD,	    // 64 bit
        FLOAT,	    // 32 bit, floating point
        DOUBLE,	    // 64 bit, floating point
    };

}

#include "UTIL.h"
#include "SYSCALL.h"
#include "GLOBAL.h"


#endif
